package com.mayikt.member.mapper;

import com.mayikt.member.entity.UserTokenDo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @Classname UserTokenMapper
 * @Description SpringBoot SpringCloud 构建微服务电商平台。
 * @Created by CHEN JIN LONG
 * @Date 2019/1/25 11:18
 * @Version 1.0
 */
public interface UserTokenMapper {


    @Update("UPDATE `meite_user_token` SET `isAvailability`=1, `updateTime`=NOW() WHERE `token`=#{token}")
    int updateAvailability(@Param("token") String token);

    @Select("select * from `meite_user_token` where userId=#{userId} and loginType=#{loginType}  and isAvailability='0'")
    UserTokenDo selectByUserIdAndLoginType(@Param("userId") Long userId, @Param("loginType") String loginType);

    @Insert("INSERT INTO `meite_user_token` (`token`, `loginType`, `deviceInfo`, `userId`, `createTime`) VALUES (#{token}, #{loginType}, #{deviceInfo}, #{userId}, NOW())")
    int insertUserToken(UserTokenDo userTokenDo);

}
